/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package runebound.ui.combate;

import runebound.combate.LineaRegistroString;
import runebound.combate.RBRegistroInformacion;
import runebound.manejadores.RBControladorJuego;
import runebound.manejadores.eventos.combate.RBEventoTestResultSinAccion;
import runebound.manejadores.eventos.combate.RBEventoTestResultado;
import runebound.modelo.heores.Heroe;
import runebound.modelo.monstruos.Monstruo;
import runebound.modelo.monstruos.comportamientos.AntesDeCombateTest;
import runebound.random.Tirada;
import runebound.ui.commons.RBTiradaDadosDiezListener;

/**
 *
 * @author Miguel (alakat@gmail.com)
 */
public class RBAntesCombateTestPanel extends RBAntesCombatePanel implements RBTiradaDadosDiezListener{

    private AntesDeCombateTest test;
    private Monstruo monstruo;
    private Heroe heroe;
    /**
     * Creates new form RBTestAntesCombatePanel
     */
    public RBAntesCombateTestPanel() {
        initComponents();
        this.resultadoLabel.setVisible(false);
        this.aceptarButton.setVisible(false);
        this.rBDadosDiezPanel1.addListener(this);
    }

    public void setTest(AntesDeCombateTest test) {
        this.test = test;
        this.descripcionText.setText(test.getTextoPrueba());
        this.sucesoExito.setText(test.getTextoExito());
        this.sucesoFracaso.setText(test.getTextoFracaso());
    }

    
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel3 = new javax.swing.JLabel();
        descripcionText = new javax.swing.JLabel();
        rBDadosDiezPanel1 = new runebound.ui.commons.RBDadosDiezPanel();
        sucesoExito = new javax.swing.JLabel();
        tituloExito = new javax.swing.JLabel();
        tituloFracaso = new javax.swing.JLabel();
        sucesoFracaso = new javax.swing.JLabel();
        aceptarButton = new javax.swing.JButton();
        resultadoLabel = new javax.swing.JLabel();

        jLabel3.setText("jLabel3");

        descripcionText.setText("Prueba de Fisico (15)");

        sucesoExito.setText("jLabel2");

        tituloExito.setText("Exito");

        tituloFracaso.setText("Fracaso");

        sucesoFracaso.setText("jLabel5");

        aceptarButton.setText("Continuar");
        aceptarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aceptarButtonActionPerformed(evt);
            }
        });

        resultadoLabel.setFont(new java.awt.Font("Lucida Grande", 1, 18)); // NOI18N
        resultadoLabel.setForeground(new java.awt.Color(204, 0, 0));
        resultadoLabel.setText("Exito!");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(37, 37, 37)
                            .addComponent(descripcionText, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(98, 98, 98)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(rBDadosDiezPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(aceptarButton))
                                .addComponent(tituloFracaso))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(tituloExito)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(sucesoFracaso, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(sucesoExito, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(resultadoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(40, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(19, Short.MAX_VALUE)
                .addComponent(descripcionText, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(sucesoExito)
                            .addComponent(tituloExito)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(resultadoLabel)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sucesoFracaso)
                    .addComponent(tituloFracaso))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(rBDadosDiezPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(aceptarButton))))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void aceptarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptarButtonActionPerformed
        //TODO sen evento
        RBControladorJuego.getInstance().recibirEvento(new RBEventoTestResultSinAccion());
    }//GEN-LAST:event_aceptarButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton aceptarButton;
    private javax.swing.JLabel descripcionText;
    private javax.swing.JLabel jLabel3;
    private runebound.ui.commons.RBDadosDiezPanel rBDadosDiezPanel1;
    private javax.swing.JLabel resultadoLabel;
    private javax.swing.JLabel sucesoExito;
    private javax.swing.JLabel sucesoFracaso;
    private javax.swing.JLabel tituloExito;
    private javax.swing.JLabel tituloFracaso;
    // End of variables declaration//GEN-END:variables

    void setNoTest() {
        this.descripcionText.setText("<html>Sin prueba antes del combate</html>");
        this.tituloExito.setVisible(false);
        this.tituloFracaso.setVisible(false);
        this.sucesoExito.setVisible(false);
        this.sucesoFracaso.setVisible(false);
        this.aceptarButton.setVisible(true);
        this.rBDadosDiezPanel1.setVisible(false);
    }

    @Override
    public void tiraradaRealizada(Tirada tirada) {
        test.antesDeCombate(this.monstruo, this.heroe, tirada,this);
        this.resultadoLabel.setVisible(true);
    }

    @Override
    public void repetirTiradaAsignada() {
        RBRegistroInformacion.getInstance().registro(new LineaRegistroString("Se activa repetir tirada"));
    }

    public void setMonstruo(Monstruo monstruo) {
        this.monstruo = monstruo;
    }

    public void setHeroe(Heroe heroe) {
        this.heroe = heroe;
    }
    
    
    public void setExitoTirada(){
        this.resultadoLabel.setText("Exito!");
    }
    
    public void setFracasoTirada(){
        this.resultadoLabel.setText("FALLO");
    }
}
